function []=plot_AV_cell(AV_data,exp_nbr,cell_nbr)

if exp_nbr>1000
    for ind=1:length(AV_data)
        if AV_data(ind).ExpID==exp_nbr
            exp_nbr=ind;
        end
    end
end

nbr_frames=size(AV_data(exp_nbr).raw_act,1);

[ROI_act_ms]=map_ROI_act_to_aux_data(AV_data(exp_nbr).raw_act(:,cell_nbr),AV_data(exp_nbr).frame_times(1:nbr_frames),length(AV_data(exp_nbr).PS));

velP_ind=((smooth2(abs(AV_data(exp_nbr).velP),500))>0.0009);
velM_ind=((smooth2(abs(AV_data(exp_nbr).velM),500))>0.0009);
velP_ind=downsample(velP_ind,10);
velM_ind=downsample(velM_ind,10);

std_noise=sqrt(sum((AV_data(exp_nbr).raw_act(AV_data(exp_nbr).raw_act(:,cell_nbr)<1,cell_nbr)-1).^2/sum(AV_data(exp_nbr).raw_act(:,cell_nbr)<1)));
if sum(AV_data(exp_nbr).raw_act(:,cell_nbr)>(1+3.7*std_noise))>100
    disp(['cell is active - threshold is ' num2str(1+3.7*std_noise)])
else
    disp(['cell is not active - threshold is ' num2str(1+3.7*std_noise)])
    %return
end


% % %if length(AV_data(exp_nbr).shutter_open)==3
% %     pb_onsets(1)=AV_data(exp_nbr).shutter_open(1);
% %     pb_onsets(2:4)=find(diff(AV_data(exp_nbr).PS(AV_data(exp_nbr).shutter_open(2):end)>0.03)>0)+AV_data(exp_nbr).shutter_open(2);
% %     pb_offsets=find(diff(AV_data(exp_nbr).PS(AV_data(exp_nbr).shutter_open(2)+1000:end)>0.03)<0)+AV_data(exp_nbr).shutter_open(2);
% %     pb_dur=pb_offsets(1)-pb_onsets(2);
% % % elseif length(AV_data(exp_nbr).shutter_open)==3
% % %     pb_onsets(1)=AV_data(exp_nbr).shutter_open(1);
% % %     pb_onsets(2:4)=find(diff(AV_data(exp_nbr).PS(AV_data(exp_nbr).shutter_open(3):end)>0.1)>0)+AV_data(exp_nbr).shutter_open(3);
% % %     pb_offsets=find(diff(AV_data(exp_nbr).PS(AV_data(exp_nbr).shutter_open(3)+1000:end)>0.1)<0)+AV_data(exp_nbr).shutter_open(3);
% % %     pb_dur=pb_offsets(1)-pb_onsets(2);
% % % elseif length(AV_data(exp_nbr).shutter_open)>2
% % %     pb_onsets=AV_data(exp_nbr).shutter_open+1000;
% % %     pb_dur=pb_onsets(2)-pb_onsets(1)-2000;
% % % else
% % %     pb_onsets=[];
% % % end
% % pb_onsets=pb_onsets+1000;
% % pb_dur=pb_dur-2500;
% % 
% % for jnd=1:length(pb_onsets)
% %     try
% %     pb_snips(:,jnd)=ROI_act_ms(pb_onsets(jnd):pb_onsets(jnd)+pb_dur);
% %     end
% % end

% % % figure;
% % % hold on
% % % set(gcf,'color','k')
% % % plotrange=floor(pb_onsets(1)/10):floor((pb_onsets(1)+pb_dur)/10);
% % % for ind=1:size(pb_snips,2)
% % %     plotrange=floor(pb_onsets(ind)/10):floor((pb_onsets(ind)+pb_dur)/10);
% % %     area([1:10:10*length(plotrange)],11.5*(velM_ind(plotrange)&~velP_ind(plotrange))+(ind-1)*12-3.5,(ind-1)*12-3.5,'facecolor',[0 1 0]*0.15,'linestyle','none')
% % %     area([1:10:10*length(plotrange)],11.5*(velP_ind(plotrange)&velM_ind(plotrange))+(ind-1)*12-3.5,(ind-1)*12-3.5,'facecolor',[1 1 1]*0.3,'linestyle','none')
% % %     area([1:10:10*length(plotrange)],11.5*(velP_ind(plotrange)&~velM_ind(plotrange))+(ind-1)*12-3.5,(ind-1)*12-3.5,'facecolor',[1 1 0]*0.25,'linestyle','none')
% % %     plot(pb_snips(:,ind)+(ind-1)*12,'color',[0 0.4 0],'linewidth',1.5)
% % %     plot([1:10:10*length(plotrange)],(velM_ind(plotrange))+(ind-1)*12-1.5,'g','linewidth',1.5)
% % %     plot([1:10:10*length(plotrange)],(velP_ind(plotrange))+(ind-1)*12-3,'r','linewidth',1.5)
% % %     %area([1:10:10*length(plotrange)],1*velP_ind(plotrange)+(ind-1)*9,(ind-1)*9,'facecolor',[1 1 1]*0.3,'linestyle','none')
% % % end
% % % plot(pb_snips(:,1),'w','linewidth',1.5)
% % % 
% % % axis off






% % % ps_triggered_activity(velP_ind,velM_ind,ROI_act_ms);
% % % xcorr_act_pupil(ROI_act_ms,AV_data(exp_nbr).pupil_diam,AV_data(exp_nbr).pupil_pos,AV_data(exp_nbr).iframe_times,length(AV_data(exp_nbr).PS))

type=(velP_ind&velM_ind)+2*(velP_ind&~velM_ind)+3*(~velP_ind&velM_ind);

for jnd=1:4
    act_ind(jnd,1)=mean(AV_data(exp_nbr).raw_act(type(round(AV_data(exp_nbr).frame_times(1:nbr_frames)/10))==(jnd-1),cell_nbr));
    act_ind(jnd,2)=std(AV_data(exp_nbr).raw_act(type(round(AV_data(exp_nbr).frame_times(1:nbr_frames)/10))==(jnd-1),cell_nbr))/sqrt(sum(type(round(AV_data(exp_nbr).frame_times(1:nbr_frames)/10))==(jnd-1)));
end

figure
set(gcf,'color','k','menubar','none');
set(gcf,'position',[-651 576 3252 420])
axes('position',[0 0 1 1],'color','k');
hold on

area([1:10:10*length(velP_ind)],10*(velP_ind&~velM_ind),'linestyle','none','facecolor',[1 1 0]*0.25);
area([1:10:10*length(velP_ind)],10*(velM_ind&~velP_ind),'linestyle','none','facecolor',[0 1 0]*0.15);
area([1:10:10*length(velP_ind)],10*(velM_ind&velP_ind),'linestyle','none','facecolor',[1 1 1]*0.1);

plot(AV_data(exp_nbr).frame_times(1:nbr_frames),AV_data(exp_nbr).raw_act(:,cell_nbr),'w');
% plot(5*AV_data(exp_nbr).velP+0.3,'y');
% plot(5*AV_data(exp_nbr).velM+0.6,'g');
plot([1:10:10*length(velP_ind)],0.2*velP_ind+0.1,'y');
plot([1:10:10*length(velM_ind)],0.2*velM_ind+0.5,'g');

axis tight
% axis off
box off
% % % 
% % % figure;
% % % hold on
% % % errorbar(act_ind(:,1),act_ind(:,2),'linestyle','none','color',[1 1 1]*0.5,'linewidth',2)
% % % plot(act_ind(:,1),'ko','linewidth',3,'markersize',10)
% % % set(gca,'xtick',[1:4])
% % % ylabel('dF/F')
% % % xlabel('condition')
% % % 
% % % 
% % % 
% % % 
